﻿-- exec [SP_LogoInformation] '2011-12-11'    
alter PROCEDURE [dbo].[SP_LogoInformation]     
 @CurrentDate DateTime = null,    
 @IsPreview BIT = 0    
AS    
BEGIN    
     
 DECLARE @LogoId INT;    
    
 SELECT TOP 1 @LogoId = li.id     
 FROM LogoInformation li     
 WHERE     
  li.CurrentDate=ISNULL(@CurrentDate,li.CurrentDate)     
  AND (li.isDeleted is null OR li.isDeleted = 0 )    
  AND IsActive = CASE WHEN @IsPreview = 0 THEN 1 ELSE IsActive END    
 ORDER BY CurrentDate DESC    
     
 --print (@LogoId);     
    
 IF(@LogoId > 0)    
 BEGIN    
    
 select * from LogoInformation li    
 where li.id = @LogoId;    
    
 Select tl.Description as MenuName , d.* from LogoDetail d inner join tblLookup tl on tl.LookUpID=d.MenuId     
 where d.LogoInformationId in (select li.Id from LogoInformation li where li.id = @LogoId)    
    
 SELECT * FROM LogoDetailDetail ddl     
   
 WHERE ddl.LogoDetailId IN     
 (    
  SELECT ld.Id FROM LogoDetail ld     
  INNER JOIN tblLookup tl     
  ON tl.LookUpID=ld.MenuId     
  WHERE ld.LogoInformationId IN     
  (    
   SELECT li.Id FROM LogoInformation li    
   where li.id = @LogoId    
  )  
     
  --SELECT li.Id FROM LogoInformation li    
  --WHERE li.CurrentDate=@CurrentDate    
 )  
 order by ddl.OrderNo asc     
 END    
     
END    
    
    
    GO
    
    INSERT INTO [tblLookup]
           ([LookUpID]
           ,[LookUpCode]
           ,[LookName]
           ,[Description]
           ,[Active]
           ,[LastModifiedDate]
           ,[UserID]
           ,[ExtraData])
     VALUES
           (13
           ,'Menu'
           ,'Menu'
           ,'Right Panel'
           ,1
           ,null
           ,null
           ,null)
GO



    